package ui.panel
{

	import beans.TowerBean;

	import flash.events.MouseEvent;
	import flash.geom.Point;

	import globals.Global;

	import ui.component.Grid;
	import ui.component.Page;
	import ui.panel.towers.TowerInfo;

	/**
	 * 建设炮塔
	 */
	public class TowerPanel extends BasePanel
	{
		private var _towerItems:Array;
		public var buildPoint:Point;

		public function TowerPanel()
		{
			super();
			pid = PanelType.TOWER_PANEL;
			updateTitle("建设炮塔");
		}

		override protected function initUI():void
		{
			super.initUI();

			_towerItems = new Array();
			var towerInfo:TowerInfo;

			for(var i:int = 0; i < 4; i++)
			{
				towerInfo = new TowerInfo();
				towerInfo.x = 25 + i * 143;
				towerInfo.y = 50;
				this.addChild(towerInfo);
				_towerItems.push(towerInfo);
			}
			//TODO：测试
			var bean:TowerBean = new TowerBean();
			bean.id = 123;
			bean.image = "tower1b";
			bean.name = "冰冻";
			bean.desc = "asdmasdjiasod";
			bean.range = 10;
			bean.interval = 10;

			updateTower(bean);
		}

		public function updateTower(bean:TowerBean):void
		{
			for each(var towerInfo:TowerInfo in _towerItems)
			{
				towerInfo.update(bean);
			}
		}

		override public function clear():void
		{
			for each(var towerInfo:TowerInfo in _towerItems)
			{
				towerInfo.clear();
			}
		}
	}
}